<template>
	<view>
		<view v-for="(item,index) in list" :key="index" class=" u-flex u-padding-20  list" @click="go(item)">
			<u-image :src="item.cover" width="100" height="100"></u-image>
			<view class="u-margin-left-20" style="width: 600rpx;">
				<view style="font-weight: bold;">{{item.goodsName}}</view>
				<view class="u-flex u-row-between u-margin-top-20">
					<view style="color: #FABE00;">￥{{item.price}}</view>
					<view class="btn" @click.stop="buy(item)">购买</view>
				</view>
			</view>
		</view>
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import payway from '@/common/wxpay.js';
	export default{
		data(){
			return{
				
			}
		},
		props:{
			list:{
				type:Array,
			}
		},
		methods:{
			buy(item) {
				// goodsType == 1 需要收货
				if(item.goodsType==1){
					this.$u.post('/api/indent/affirm', {
						goods_id: item.id,
					    num: 1,
					}).then(res => {
		                uni.navigateTo({
		                	url:"../../pages/sure_book/index?info="+encodeURIComponent(JSON.stringify(res))
		                })
					}).catch(err => {
								
					})
				}else{
		        
				}
	
			},
			go(item){
				uni.navigateTo({
					url:'../../pages/store/goodDetail?id='+item.id
				})
			}
		}
	}
</script>

<style>
	.list {
		background: #fff;
		width: 700rpx;
		margin: 20rpx auto;
		padding: 20rpx;
	}
	.btn {
		padding: 7rpx 15rpx;
		background: #fff;
		border-radius: 20rpx;
		color: #fff;
		
		background: #FFA200;
		font-size: 24rpx;
	}
</style>
